abc(Certomà 2020)
library(tidyverse)
## -- Attaching packages ----------------- tidyverse 1.3.0 --
## √ ggplot2 3.3.2 √ purrr 0.3.4
## √ tibble 3.0.3 √ dplyr 1.0.2
## √ tidyr 1.1.2 √ stringr 1.4.0
## √ readr 1.4.0 √ forcats 0.5.0
## -- Conflicts -------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(raster)
## Loading required package: sp
##
## Attaching package: 'raster'
## The following object is masked from 'package:plotly':
##
## select
## The following object is masked from 'package:dplyr':
##
## select
## The following object is masked from 'package:tidyr':
##
## extract
library(weathermetrics)
GB_auto <- raster::getData('GADM',
country="GBR",
level=0,
#set the path to store your data in
path='',
download=TRUE)
GBclim <- raster::getData("worldclim",
res=5,
var="tmean",
#set the path to store your data in
path='',
download=TRUE)
month <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
names(GBclim) <- month
GBtemp <- GBclim %>%
crop(., GB_auto)%>%
#WorldClim data has a scale factor of 10!
mask(., GB_auto)/10
alldf <- GBtemp %>%
as.data.frame()%>%
pivot_longer(
cols = 1:12,
names_to = "Month",
values_to = "Temp")%>%
drop_na()
jan<-filter(alldf, Month=="Jan")
jun<-filter(alldf, Month=="Jun")
# give axis titles
x <- list (title = "Temperature")
y <- list (title = "Frequency")
# set the bin width
xbinsno<-list(start=-5, end=20, size = 2.5)
# plot the histogram calling all the variables we just set
ihist<-plot_ly(alpha = 0.6) %>%
add_histogram(x = jan$Temp,
xbins=xbinsno, name="January") %>%
add_histogram(x = jun$Temp,
xbins=xbinsno, name="June") %>%
layout(barmode = "overlay", xaxis=x, yaxis=y)
ihist
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
Certomà, Chiara. 2020. “Digital Social Innovation and Urban Space: A Critical Geography Agenda.” Urban Planning 5 (4): 8–19. https://doi.org/10.17645/up.v5i4.3278.